home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / BlobMgr / Library Folder / Index.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-21  |  872 b   |  56 lines  |  [TEXT/KAHL]

  1. # include    "BlobMgr.h"
  2.  
  3.  
  4. /*
  5.  * Get the handle of the (i)th blob in the list.  The first
  6.  * blob is numbered 0.
  7.  */
  8.  
  9. pascal BlobHandle
  10. GetBlobHandle (BlobSetHandle bSet, short i)
  11. {
  12. BlobHandle    b;
  13.  
  14.     for (b = FirstBlob (bSet); b != nil; b = NextBlob (b))
  15.     {
  16.         --i;
  17.         if (i < 0) break;        /* found it */
  18.     }
  19.     return (b);
  20. }
  21.  
  22.  
  23. /*
  24.  * Get the index of the given blob in the list, given its handle.
  25.  * The blob is assumed to be in the set.  Returns a number from
  26.  * 0 to BlobSetSize (bSet)-1.
  27.  */
  28.  
  29. pascal short
  30. GetBlobIndex (BlobSetHandle bSet, BlobHandle b)
  31. {
  32. BlobHandle    b2;
  33. short        i;
  34.  
  35.     i = 0;
  36.     for (b2 = FirstBlob (bSet); b2 != nil; b2 = NextBlob (b2))
  37.     {
  38.         if (b == b2) break;        /* found it */
  39.         ++i;
  40.     }
  41.     return (i);
  42. }
  43.  
  44.  
  45. pascal short
  46. BlobSetSize (BlobSetHandle bSet)
  47. {
  48. BlobHandle    b;
  49. short        i;
  50.  
  51.     for (i = 0, b = FirstBlob (bSet); b != nil; b = NextBlob (b))
  52.     {
  53.         ++i;
  54.     }
  55.     return (i);
  56. }